package cn.linjianhui.api.client;

import cn.linjianhui.api.client.invoker.ClientAuthenticator;
import cn.linjianhui.api.client.invoker.RPCInvoker;
import cn.linjianhui.api.client.invoker.Serializer;
import cn.linjianhui.api.client.invoker.impl.HttpInvoker;
import org.springframework.util.StringUtils;

public class RPCInvokerFactory {
    public static RPCInvoker GetInvoker(String serviceUri, String baseAddress, String[] parameters, Class<?> returnType,
                                        Class<?> genericType, ClientAuthenticator authenticator, DataFormat dataFormat) {
        Serializer serializer = SerializerFactory.GetSerializer(dataFormat);
        return new HttpInvoker(serviceUri, StringUtils.trimTrailingCharacter(baseAddress, '/'),
                parameters, returnType, genericType, authenticator, serializer, dataFormat);
    }
}
